define(function(require,exports,module){
    
    var signHtml = '{{{signLottery signStatus}}}';
    //AJAX请求类
	var Ajax = require('extendModel/AjaxReturn');
    //判断用户验证信息
      $.ajax({
            type:"post",
            url:"/member_borrow/businessUserIdentify.html?randomTime=" + (new Date()).getTime(),
            dataType:"json",
            cache:false,
            success:function(json){
            	$(".account_home_msg dl").html(Handlebars.compile(require("../../tpl/member_borrow/main_info.tpl"))(json));
                //判断是否开通第三方账户
                if(json.openApi){//托管版
                  if(json.apiStatus == 0){
                      $(".noAuthentication").slideDown();
                  }
                }else{//标准版
              	  if(json.realNameStatus==0 || json.realNameStatus==-1){
              		  $(".noAuthentication").slideDown();
              	  }
                }
            }
       });
      
    //可提现金额、正在借款项目、下一个待还日期
      $.ajax({
        url:"/member_borrow/businessHandleMoney.html?randomTime=" + (new Date()).getTime(),
        type:"post",
        dataType:"json",
        cache:false,
        success:function(json){
            $(".member_borrow_home").html(Handlebars.compile(require("../../tpl/member_borrow/main_total.tpl"))(json));
        }
    });
	require.async('common1',function(){
		$(".account_home_con").tabChange({
			isClick:true,
            isHover:false,
			childLi:"ul li",//tab选项卡
			childContent:".con",//tab内容
			hoverClassName:"hover",//选中当前选项卡的样式
			callBack:false	
		});
	});
    
	//可投借款
    var tpl_invest = require('../../tpl/member/main_invest.tpl');
    Ajax.ajaxPacket('/member/investList.html','get',tpl_invest,'#main_invest_2');

    //收款信息
    var tpl_collection = require('../../tpl/member/main_collection.tpl');
    Ajax.ajaxPacket('/member/investCollectionList.html','get',tpl_collection,'#main_collection_2');
    
    //交易记录 
    var tpl_trade = require('../../tpl/member/main_trade.tpl');
    Ajax.ajaxPacket('/member/investTransactionLog.html','get',tpl_trade,'#tradeLogTable');
    
    //借款中的项目
    var tpl_borrow = require('../../tpl/member_borrow/main_borrow.tpl');
    Ajax.ajaxPacket('/member_borrow/businessBid.html','get',tpl_borrow,"#main_invest");
    
    //还款中的项目
    var tpl_repayment = require('../../tpl/member_borrow/main_repayment.tpl');
    Ajax.ajaxPacket('/member_borrow/businessRepayment.html?randomTime=' + (new Date()).getTime(),'get',tpl_repayment,"#main_collection");
    
    
    $("#jianhao").click(function(){
    	$(".noAuthentication").hide();
    });
    //用户签到动作
    $(".nosign").live("click",function(){
        $.ajax({
            type:"post",
            url:"/user/doSign.html?randomTime=" + (new Date()).getTime(),
            dataType:'json',
            cache:false,
            success:function(json){
                if(json.result) {
                    //查询签到抽奖信息
                    $.ajax({
                        type:"post",
                        url:"/member/getSignStatus.html?randomTime=" + (new Date()).getTime(),
                        dataType:"json",
                        cache:false,
                        success:function(json){
                            $(".sign_tip").html(Handlebars.compile(signHtml)(json));
                            //提示效果
                            require.async(['/plugins/poshytip/tip-yellowsimple/tip-yellowsimple.css','/plugins/poshytip/jquery.poshytip.min'],function(){
                                $('.textTips').poshytip({
                                    className: 'tip-yellowsimple',
                                    showTimeout: 1,
                                    alignTo: 'target',
                                    alignX: 'center',
                                    alignY: 'top',
                                    offsetY: 10,
                                    allowTipHover:false
                                });
                            });
                        }
                    });
                }
            }
        });
    });
});

